/////////////////////////////////////////////////////////////////
//	File Name	:	"CBase.h"
//
//	Author		:	Sec-C-Games
//
//	Purpose		:	To hold all common data and functionality
//					for  game objects.
/////////////////////////////////////////////////////////////////
#pragma once
#include "IBaseInterface.h"
#include "SGD_Math.h"
#include <Windows.h>

enum {OBJ_BASE, OBJ_PLAYER=0, OBJ_ENEMY, OBJ_OBJ , OBJ_NADE, OBJ_SWITCH, OBJ_BULLET, OBJ_PICKUP};

class CBase : public IBaseInterface
{
protected:
	int m_nType;
private:
	unsigned int m_iRefCount;	// how many objects have a pointer to me?

	bool m_bIsOnscreen;

	float m_fMass;
	//	position
	tVector2D m_vPosition;
	//	velocity
	tVector2D m_vVelocity;

	//int m_nWidth;
	//int m_nHeight;
public:

	CBase(void);
	virtual ~CBase(void);

	///////////////////////////////////////////
	//	Function:	Accessors
	//
	//	Purpose:	To get the specified type
	///////////////////////////////////////////
	inline tVector2D GetPosition(void)	   {return m_vPosition;}
	inline tVector2D GetVelocity(void)	   {return m_vVelocity;}
	inline float	 GetMass(void)		   {return m_fMass;}
	inline int		 GetType(void)		   {return m_nType;}
	inline bool		 IsOnscreen(void)      {return m_bIsOnscreen;}

	////////////////////////////////////////////
	//	Function:	Modifiers
	//
	//	Purpose:	To set the specified type
	////////////////////////////////////////////
	inline void SetPosX(float nPosX)			{ m_vPosition.fX = nPosX; }
	inline void SetPosY(float nPosY)			{ m_vPosition.fY = nPosY; }
	inline void SetVelX(float nVelX)			{ m_vVelocity.fX = nVelX; }
	inline void SetVelY(float nVelY)			{ m_vVelocity.fY = nVelY; }
	
	//void SetSourceRect(LONG left, LONG top, LONG right, LONG bottom);
	//	3 steps during execution:
	//		1.	Input
	//		2.	Update
	virtual void Update(float fElapsedTime );

	//		3.	Draw
	virtual void Render(void);

	virtual bool CheckCollision(CBase* pBase);

	//RECT GetRect() {return m_rSrcRCT;}
	//	For reference counting:
	void AddRef(void)
	{
		m_iRefCount++;
	}
	void Release(void)
	{
		m_iRefCount--;

		if (m_iRefCount == 0)
			delete this;
	}
	virtual RECT GetCollisionRect();
};